package com.example.chapter09;

import java.util.StringTokenizer;

public class test6 {
    public static void main(String[] args) {
        String fruits = "Apple,Banana,Orange";
        String[] fruitArray = fruits.split(",");
        for (String fruit : fruitArray) {
            System.out.println(fruit);
        }

        StringTokenizer tokenizer = new StringTokenizer(fruits, ",");
        while (tokenizer.hasMoreTokens()) {
            System.out.println(tokenizer.nextToken());
        }

        String[] fruites = {"Apple", "Banana", "Orange"};
        String result = String.join(", ", fruites);
        System.out.println(result);


        StringBuilder builder = new StringBuilder();
        builder.append("Apple");
        builder.append(", ");
        builder.append("Banana");
        builder.append(", ");
        builder.append("Orange");
        String fruitss = builder.toString();
        System.out.println(fruitss);

        String text = "apple,banana;orange";
        String[] fruits2 = text.split("[,;]");
        for (String fruit : fruits2) {
            System.out.println(fruit);
        }

        String[] words = {"Hello", "World"};
        String text2 = String.join(" ", words);
        System.out.println(text2);

    }
}
